<?php

/**
 * This is the model class for table "pasusiasubur".
 *
 * The followings are the available columns in table 'pasusiasubur':
 * @property integer $psub_id
 * @property integer $psub_kec
 * @property integer $psub_pasubur
 * @property integer $psub_peskbaktif
 * @property double $psub_tkkesehatan
 * @property integer $psub_tahun
 *
 * The followings are the available model relations:
 * @property Kecamatan $psubKec
 */
class Pasusiasubur extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Pasusiasubur the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'pasusiasubur';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('psub_kec, psub_pasubur, psub_peskbaktif, psub_tahun', 'numerical', 'integerOnly'=>true),
			array('psub_tkkesehatan', 'numerical'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('psub_id, psub_kec, psub_pasubur, psub_peskbaktif, psub_tkkesehatan, psub_tahun', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'psubKec' => array(self::BELONGS_TO, 'Kecamatan', 'psub_kec'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'psub_id' => 'Psub',
			'psub_kec' => 'Psub Kec',
			'psub_pasubur' => 'Psub Pasubur',
			'psub_peskbaktif' => 'Psub Peskbaktif',
			'psub_tkkesehatan' => 'Psub Tkkesehatan',
			'psub_tahun' => 'Psub Tahun',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('psub_id',$this->psub_id);
		$criteria->compare('psub_kec',$this->psub_kec);
		$criteria->compare('psub_pasubur',$this->psub_pasubur);
		$criteria->compare('psub_peskbaktif',$this->psub_peskbaktif);
		$criteria->compare('psub_tkkesehatan',$this->psub_tkkesehatan);
		$criteria->compare('psub_tahun',$this->psub_tahun);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}